﻿namespace GoodAdmin.Web.Core;

/// <summary>
/// 人员管理控制器
/// </summary>
[ApiDescriptionSettings("System", Tag = "文件管理")]
[Route("/system/file")]
public class FileController:IDynamicApiController
{
    private readonly IFileService _fileService;

    public FileController(IFileService fileService)
    {
        _fileService = fileService;
    }

    [HttpPost("download")]
    [DisplayName("下载文件")]
    public async Task<IActionResult> Download(BaseIdInput input)
    {
        return await _fileService.Download(input);
    }

    [HttpGet("downloadByPath")]
    [DisplayName("根据文件地址下载文件")]
    public async Task<IActionResult> Download(string path, string name)
    {
        return await _fileService.Download(path,name);
    }

    [HttpPost("upload")]
    [DisplayName("上传文件")]
    public async Task UploadFile(IFormFile file, string type)
    {
        await _fileService.UploadFileAndSaveDb(file, type);
    }

    [HttpPost("batchUpload")]
    [DisplayName("批量上传文件")]
    public async Task BatchUploadFile(IList<IFormFile> files, string type)
    {
        await _fileService.BatchUploadFileAndSaveDb(files, type);
    }
}
